package racing;

import utils.Line;
import utils.Polygonal;
import utils.Position;

public class Track {
	private Polygonal left;
	private Polygonal right;
	private Line exit;
	private Line goal;
	
	/**
	 * @param left
	 * @param right
	 * @param exit
	 * @param goal
	 */
	public Track(Polygonal left, Polygonal right) {
		super();
		this.left = left;
		this.right = right;
		float xr = this.right.getSegments().elementAt(0).getX();
		float yr = this.right.getSegments().elementAt(0).getY();
		float xl = this.left.getSegments().elementAt(0).getX();
		float yl = this.left.getSegments().elementAt(0).getY();
		Line line = new Line(new Position(xl,yl) , new Position(xr,yr));
		this.exit = line;
		
		xr = this.right.getSegments().elementAt(this.right.getSegments().size()-1).getX();
		yr = this.right.getSegments().elementAt(this.right.getSegments().size()-1).getY();
		xl = this.left.getSegments().elementAt(this.left.getSegments().size()-1).getX();
		yl = this.left.getSegments().elementAt(this.left.getSegments().size()-1).getY();
		line = new Line(new Position(xl,yl) , new Position(xr,yr));
		
		//Line out = new Line(new Position(,this.left.getSegments().elementAt(0).getY()) , new Position(this.right.getSegments().elementAt(0).getX(),this.right.getSegments().elementAt(this.right.getSegments().size()-1).getY()));
		
		this.goal = line;
	}

	/**
	 * @return the left
	 */
	public Polygonal getLeft() {
		return left;
	}

	/**
	 * @param left the left to set
	 */
	public void setLeft(Polygonal left) {
		this.left = left;
	}

	/**
	 * @return the right
	 */
	public Polygonal getRight() {
		return right;
	}

	/**
	 * @param right the right to set
	 */
	public void setRight(Polygonal right) {
		this.right = right;
	}

	/**
	 * @return the exit
	 */
	public Line getExit() {
		return exit;
	}

	/**
	 * @param exit the exit to set
	 */
	public void setExit(Line exit) {
		this.exit = exit;
	}

	/**
	 * @return the goal
	 */
	public Line getGoal() {
		return goal;
	}

	/**
	 * @param goal the goal to set
	 */
	public void setGoal(Line goal) {
		this.goal = goal;
	}
	
	public boolean isExitVertical(){
		boolean result = false;
		
		if(exit.getA().getX() == exit.getB().getX()){
			result = true;
		}		
		
		return result;
	}
	
	
	
	
}
